#include <bits/stdc++.h>
using namespace std;

int n;
string str;

int main()
{
    cin >> n >> str;

    long long s = 0, h = 0, y = 0;
    for (int i = 0; i < n; i++)
    {
        char ch = str[i];
        if (ch == 's') s++;
        else if (ch == 'h') h += s;
        else if (ch == 'y') y += h;
    }

    cout << y << endl;
    return 0;
}